﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;

namespace HHF.Email
{
	public static class Emailer
	{
		public static bool SendEmail(string to, string subject, string message)
		{
#if DEBUG
			System.Diagnostics.EventLog.WriteEntry("New Email", String.Join(";", new[] { to, subject, message }));
			return true;
#else 

			try
			{
				var msg = new MailMessage(Constants.DefaultEmail, to);
				msg.Subject = subject;
				msg.Body = message;
				msg.IsBodyHtml = true;

				var client = new SmtpClient();
				client.Send(msg);

				return true;
			}
			catch (Exception ex)
			{
				//catch the error but don't 
				System.Diagnostics.EventLog.WriteEntry("Application", ex.ToString());
				return false;
			}

#endif
		}
	}
}
